<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>图书馆座位预约系统 - 预约历史</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <style>
        body {
            background: #f0f2f5;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 60px 0 80px;
        }

        .container {
            max-width: 1200px;
            margin: 30px auto;
            padding: 40px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        h2 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 40px;
            font-size: 28px;
        }

        table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            margin-bottom: 30px;
            overflow: hidden;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }

        th, td {
            padding: 16px;
            text-align: left;
            border-bottom: 1px solid #e0e0e0;
        }

        th {
            background: #3498db;
            color: white;
            font-weight: 600;
            text-transform: uppercase;
            font-size: 14px;
        }

        tr {
            transition: background 0.2s ease;
        }

        tr:hover {
            background: #f5f9ff;
        }

        .status {
            display: inline-block;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 14px;
            font-weight: 500;
        }

        .status.active {
            background: #e8f5e9;
            color: #2e7d32;
        }

        .status.cancelled {
            background: #ffebee;
            color: #c62828;
        }

        .action-btn {
            padding: 8px 16px;
            border-radius: 6px;
            background: #ff5252;
            color: white;
            text-decoration: none;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .action-btn:hover {
            background: #ff1744;
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(255, 82, 82, 0.2);
        }

        .back-link {
            display: inline-block;
            margin-top: 25px;
            color: #3498db;
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s ease;
        }

        .back-link:hover {
            color: #2980b9;
            text-decoration: underline;
        }

        nav {
            background: #2c3e50;
            padding: 15px 0;
            position: fixed;
            bottom: 0;
            width: 100%;
        }

        nav ul {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            justify-content: center;
            gap: 30px;
        }

        nav a {
            color: white;
            font-size: 16px;
            transition: color 0.3s ease;
        }

        nav a:hover {
            color: #3498db;
            text-decoration: none;
        }

        @media (max-width: 768px) {
            .container {
                padding: 25px;
                margin: 20px;
            }

            table {
                display: block;
                overflow-x: auto;
            }

            th, td {
                min-width: 120px;
            }

            nav ul {
                gap: 15px;
                flex-wrap: wrap;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <h2>📚 预约历史</h2>
    <table>
        <thead>
        <tr>
            <th>预约编号</th>
            <th>座位号</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="reservation : ${reservations}">
            <td th:text="${reservation.id}"></td>
            <td th:text="${reservation.seat.seatNumber}"></td>
            <td th:text="${#temporals.format(reservation.startTime, 'yyyy-MM-dd HH:mm')}"></td>
            <td th:text="${#temporals.format(reservation.endTime, 'yyyy-MM-dd HH:mm')}"></td>
            <td>
                <span th:class="${reservation.status == 'ACTIVE'} ? 'status active' : 'status cancelled'"
                      th:text="${reservation.status == 'ACTIVE'} ? '进行中' : '已取消'"></span>
            </td>
            <td>
                <a th:if="${reservation.status == 'ACTIVE'}"
                   th:href="@{/reservations/cancel(id=${reservation.id})}"
                   class="action-btn">取消预约</a>
            </td>
        </tr>
        </tbody>
    </table>
    <a href="/seats" class="back-link">← 返回座位选择</a>
</div>
<nav>
    <ul>
        <li><a href="/login">🔑 登录</a></li>
        <li><a href="/register">📝 注册</a></li>
        <li><a href="/announcements">📢 公告</a></li>
    </ul>
</nav>
</body>
</html>